package com.hdax.dm.utils.response;

import com.hdax.dm.exceptions.DmException;

/**
 * 公共响应数据封装工具方法类
 */
public class ResponseUtils<T> {
    //成功响应数据
    public static<T> CommonResponse<T> returnSuccess(T data){
        return  new CommonResponse<>(data);
    }
    public static<T> CommonResponse<T> returnSuccess(T data,String msg){
        return  new CommonResponse<>(data,msg);
    }

    //失败响应数据
    public static<T> CommonResponse<T> returnFail(String errorCode,String msg){
        return new CommonResponse<>(errorCode,msg);
    }

    //失败异常响应数据
    public static<T> CommonResponse<T> returnFail(DmException e){
        return new CommonResponse<>(e.getErrorCode(),e.getMessage());
    }
}
